﻿///<jscompress sourcefile="utils.js" />
/**
 * 封装Ajax</br> 参数说明：</br> opts: {'可选参数'}</br> type:
 * 请求方式:GET/POST,默认值:'GET';</br> url: 发送请求的地址, 默认值: 当前页地址;</br> data:
 * 请求参数;</br> data: string,json;</br> async: 是否异步:true/false,默认值:true;</br>
 * cache: 是否缓存：true/false,默认值:true;</br> contentType:
 * HTTP头信息，默认值：'application/x-www-form-urlencoded';</br> success:
 * 请求成功后的回调函数;</br> error: 请求失败后的回调函数;</br>
 */
;
//注册命名空间
var NameSpace = {
    register: function () {
        var arg = arguments[0];
        var arr = arg.split('.');
        var str = '';
        for (var i = 0; i < arr.length; i++) {
            str = i == 0 ? arr[i] : (str + '.' + arr[i]);
            var sval = "   if(typeof " + str + "=='undefined' ) { " + str + "= new Object(); } ";
            eval(sval) ;
        };
    }
};
//注册应用命名空间
NameSpace.register("cmedit");
cmedit.util = (function ($, window, document) {
    return {
        ajaxRequest: function (opts) {
            // 一.设置默认参数
            var defaults = {
                url: '',
                type: '',
                data: '',
                cache: true,
                async: false,
                dataType: 'json',
//                contentType: "application/json;charset=UTF-8",
                success: function () {
                },
                error: function () {
                }
            };

            // 二.用户参数覆盖默认参数
            for (var key in opts) {
                defaults[key] = opts[key];
            }
            var userInfo={
            		tenantId : "dayang.com",
            		userId : "0003",
            		token : "a",
            		userName : "dayang"
            		/*userName : "encodeURIComponent('dayang')"*/
            }
            window.sessionStorage.setItem("userInfo",JSON.stringify(userInfo));
            var userInfoItem = window.sessionStorage.getItem("userInfo");
            var userInfo = null;
            var userId = "";
            var tenantId = "";
            var userName = "";
            var token = "";
            if (userInfoItem != undefined && userInfoItem != null && userInfoItem != "" && userInfoItem != "undefined" && userInfoItem != "null") {
                userInfo = JSON.parse(userInfoItem);
                userId = userInfo.userId;
                tenantId = userInfo.tenantId;
                token = userInfo.token;
                userName=userInfo.userName;
            } else {
            	cmedit.global.forceLogout("用户信息为空！");
            }
            
            var tenantId = window.localStorage.getItem("tenantId");
            var userId = window.sessionStorage.getItem("userId");
            var token = window.sessionStorage.getItem("token");
            var userName = window.sessionStorage.getItem("userName");
            userName = encodeURIComponent(userName);
            
//            cmedit.ManuscriptSystem.updatePortalStorageExpireTime();
            // 三.开始组装ajax
            $.ajax({
                url: defaults.url,
                type: defaults.type,
                data: defaults.data,
                async: defaults.async,
                cache: defaults.cache,
                dataType: defaults.dataType,
                contentType: defaults.contentType,
                beforeSend: function (XHR) {
                    XHR.setRequestHeader("userId", userId);
                    XHR.setRequestHeader("tenantId", tenantId);
                    XHR.setRequestHeader("token", token);
                    XHR.setRequestHeader("userName", userName);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    console.log("错误信息" + errorThrown.toString());
                },
                success: defaults.success
            });
        },
        isNotEmpty: function(obj){
            var isflag = false;
            if(obj!=null&&obj!=''&&obj!=undefined&&obj!='undefined'){
                isflag = true;
            }
            return isflag;
        },
        //弹出框
        alert:function(callback,dialogBody){
//			var config = {
//				dialogBody:dialogBody,
//				title:"温馨提示",
//				noClose:false
//			};
//			Global.dialog(config);
            bootbox.setDefaults("locale","zh_CN");
//            bootbox.alert(dialogBody);
            bootbox.confirm({   
                message: dialogBody,  
                callback: callback,  
                title: "",  
            });  
        },
        /**
         * 对日期进行格式化，
         * @param date 要格式化的日期
         * @param format 进行格式化的模式字符串
         *     支持的模式字母有：
         *     y:年,
         *     M:年中的月份(1-12),
         *     d:月份中的天(1-31),
         *     h:小时(0-23),
         *     m:分(0-59),
         *     s:秒(0-59),
         *     S:毫秒(0-999),
         *     q:季度(1-4)
         * @return String
         */
        dateFormat : function (date, format){

            date = new Date(date);
            var map = {
                "M": date.getMonth() + 1, //月份
                "d": date.getDate(), //日
                "h": date.getHours(), //小时
                "m": date.getMinutes(), //分
                "s": date.getSeconds(), //秒
                "q": Math.floor((date.getMonth() + 3) / 3), //季度
                "S": date.getMilliseconds() //毫秒
            };

            format = format.replace(/([yMdhmsqS])+/g, function(all, t){
                var v = map[t];
                if (v !== undefined) {
                    if (all.length > 1) {
                        v = '0' + v;
                        v = v.substr(v.length - 2);
                    }
                    return v;
                }
                else if (t === 'y') {
                    return (date.getFullYear() + '').substr(4 - all.length);
                }
                return all;
            });
            return format;
        },
        //字节转换成其它类型的单位
        bytesToSize: function (bytes) {
            if (bytes === 0) return '0 B';
            var k = 1024;
            var sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
            var i = Math.floor(Math.log(bytes) / Math.log(k));
            return (bytes / Math.pow(k, i)).toFixed(2) + ' ' + sizes[i];
        },
        //从url中根据名称获取参数
        getParameterFromUrl: function (parameterName) {
            var reg = new RegExp("(^|&)" + parameterName + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null)return decodeURIComponent(r[2]);;
            return null;
        },
        /**
		 * 动态加载js文件
		 */
		loadScript : function(url) {
			var script = document.createElement("script");
			script.type = "text/javascript";
			script.src = url;
			document.body.appendChild(script);
		},
		/**
		 * 动态加载css文件
		 */
		loadStyles : function(url) {
			var link = document.createElement("link");
			link.type = "text/css";
			link.rel = "stylesheet";
			link.href = url;
			document.getElementsByTagName("head")[0].appendChild(link);
		},
		/**
		 * 生成随机正整数(1-100)
		 */
		randomNum : function() {
			//x上限，y下限     
		    var x = 100;     
		    var y = 1;     
		    var rand = parseInt(Math.random() * (x - y + 1) + y);     

			return rand;
		},
        /**
         * 根据稿件类型，获取稿件的前端地址
         * @param maintype 稿件类型
         * @returns
         */
        getAppPathByType : function(maintype){
        	var app;
        	if(maintype == '0'){
        		app = cmedit.util.getAppByCode("PID_Fast_cmedit_cms");
        	}
        	if(maintype == '1'){
        		app = cmedit.util.getAppByCode("PID_Fast_cmedit_wechat");
        	}
        	if(maintype == '2'){
        		app = cmedit.util.getAppByCode("PID_Fast_cmedit_weibo");
        	}
        	if(maintype == '3'){
        		app = cmedit.util.getAppByCode("PID_Fast_cmedit_tv");
        	}
        	if(maintype == '4'){
        		app = cmedit.util.getAppByCode("PID_Fast_cmedit_release");
        	}
        	return app.appUrl;
        },
        /**
         * 根据应用code从应用信息
         * 
         * @param appCode 应用代码
         * @returns
         */
        getAppByCode: function (appCode) {
            var app = "";
            $.ajax({
                type: 'POST',
                async: false,
				url: cmedit.global.portalPath + "AppController/getAppList",
				data: {
					appCode : appCode
				},
                success: function (data) {
                    if (data.status == true || data.status == "true") {
                    	app = data.data[0];
                    } else {
                        cmedit.util.alertMsgNoCancel(data.msg);
                    }
                }
            });
            return app;
        },
        /**
         * 无取消按钮的提示框
         * @param content  提示内容
         */
        alertMsgNoCancel: function (content) {
            art.dialog({
                content: content,
                height: 60,
                width: 300,
                lock: true,
                focus: true,
                zIndex: 99999999
            }, function () {
            });
        },
        /**
         * 定时关闭消息
         * @param content  提示内容
         */
        alertTimeMsgNoCancel: function (content) {
           /* art.dialog({
            	time: 1,
                content: content,
                height: 60,
                width: 300,
                lock: true,
                focus: true,
                zIndex: 99999999
            });*/
        	$("body").dyArt({
        		content:content,
        		isHide:false,
        		Time:2000
        	})
        },
        /**
         * 提示框
         * callback 回调函数
         * key 提示描述
         */
        alertMsg: function (callback, content) {
            art.dialog({content: content, height: 60, width: 300, lock: true, focus: true}, function () {
                // 先保存稿件信息
                callback(true);
            }, function () {
            });
        },
        autoResizeImage: function (maxWidth, maxHeight, objImg) {
            var img = new Image();
            img.src = objImg.src;
            var hRatio;
            var wRatio;
            var Ratio = 1;
            var w = img.width;
            var h = img.height;
            wRatio = maxWidth / w;
            hRatio = maxHeight / h;
            if (maxWidth == 0 && maxHeight == 0) {
                Ratio = 1;
            } else if (maxWidth == 0) {//
                if (hRatio < 1) Ratio = hRatio;
            } else if (maxHeight == 0) {
                if (wRatio < 1) Ratio = wRatio;
            } else if (wRatio < 1 || hRatio < 1) {
                Ratio = (wRatio <= hRatio ? wRatio : hRatio);
            }
            if (Ratio < 1) {
                w = w * Ratio;
                h = h * Ratio;
            }
            objImg.height = h;
            objImg.width = w;
        },
        getContextPath: function (pathName) {
            var index = pathName.substr(1).indexOf("/");
            var result = pathName.substr(0, index + 1);
            return result;
        },
        //显示数据加载中遮罩
        showLoading:function(select) {
            $(select).showLoading();
        },
        //隐藏数据加载中遮罩
        hideLoading:function(select) {
            $(select).hideLoading();
        },
        //弹出页面
        tipsWindowsDialog:function(title,content,width,height,drag,time,showbg,cssName){
            tipsWindown(title,content,width,height,drag,time,showbg,cssName)
        },
        /**
         * 将驼峰式命名的字符串转换为下划线大写方式。如果转换前的驼峰式命名的字符串为空，则返回空字符串。</br>
         * 例如：HelloWorld->HELLO_WORLD
         * @param name 转换前的驼峰式命名的字符串
         * @return 转换后下划线大写方式命名的字符串
         */
        underScoreName : function(name) {
        	if(cmedit.util.isNotEmpty(name)){
        		var result = name.replace(/([A-Z])/g,"_$1").toLowerCase()
                return result.toString();
        	}else{
        		return "";
        	}
            
        },

        /**
         * 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空，则返回空字符串。</br>
         * 例如：HELLO_WORLD->HelloWorld
         * @param name 转换前的下划线大写方式命名的字符串
         * @return 转换后的驼峰式命名的字符串
         */
        camelName : function(name) {
        	if(cmedit.util.isNotEmpty(name)){
//        		var re=/_(\w)/g;
        		var result = name.replace(/_(\w)/g, function(all, letter){
      	          return letter.toUpperCase();
      	        })
      	        return result.toString();
        	}else{
        		return "";
        	}
        	
        }
    };
})(jQuery, window, document);



;
///<jscompress sourcefile="loginBycas.js" />
;
/*
 * 该类主要实现单点登录功能，过渡页面
 */
cmedit.LoginBycas = (function($, window, document) {
    var thisContext;
    var loginBycasFn;
    var userId; //用户userID
    var token; //用户token
    var userName; //用户名
    var tenantId; //用户头像地址
    var cloudType; //当前系统模式(true:公有云;false:私有云)
    var orgCode; 
    var isPublish = cmedit.global.isPublish;


    var LoginBycasClass = function() {
        thisContext = this;
        thisContext.loginBycasFn = function() {};
    };
    LoginBycasClass.prototype = {
        //构造函数
        constructor: LoginBycasClass,
        init: function() {
            window.sessionStorage.setItem("dyportalServerPath", cmedit.global.portalPath);
            // thisContext.initViewStyle();
            thisContext.initEvent();
        },
		/**
		 * 初始化页面事件
		 */
		initEvent : function() {
			// 设置portal相关js
			loginBycasFn = thisContext.loginByCas;
			var systsemcmedit = cmedit.global.getAppByCode(cmedit.global.system_cmedit_cms_id,window.localStorage.getItem("tenantId"))
			// 查询版本信息
			/*$.ajax({
				async : false,
				url : cmedit.global.cmsPath + "UserInfoController/getModuleInfo",
				type : 'GET',
				success : function(data) {
					if (data.status == true || data.status == 'true') {
//						$.initHeader({
//							"divId": "CMEDIT_portal",                          //头部存放区域id
//							"highLight": systsemcmedit.appCode,   //高亮应用id
//							 "aboutInfo": [{      //需要在导航栏中关于模块要展现的信息，无属性则不展现
//	                             "aboutName":"版本信息",
//	                             "aboutCode":"Vesion",
//	                             "aboutValue":data.data.version
//	                            },{      //需要在导航栏中关于模块要展现的信息
//								  "aboutName":"升级时间",
//								  "aboutCode":"UpdateTime",
//								  "aboutValue":data.data.updateTime
//								}]
//						},loginBycasFn);
						var loginModel = window.localStorage.getItem("login_casData");
                    	if(!loginModel){
                    		$.updateStorageExpireTime();
                    		loginModel = cmedit.global.getUserInfo(cmedit.global.portalPath,window.localStorage.getItem("portalKey")).loginModel;
                    	}else{
                    		loginModel = JSON.parse(loginModel);
                    	}
                    	thisContext.loginByCas(loginModel);
					} else {
						cmedit.global.alertMsgNoCancel(data.msg);
					}
				}
			}); */
            var loginModel = window.localStorage.getItem("login_casData");
            if (!loginModel) {
                $.updateStorageExpireTime();
                loginModel = cmedit.global.getUserInfo(cmedit.global.portalPath, window.localStorage.getItem("portalKey")).loginModel;
            } else {
                loginModel = JSON.parse(loginModel);
            }
            thisContext.loginByCas(loginModel);
        },
        /**
         * 初始化页面视图
         */
        initViewStyle: function() {

        },

        /**
         * 单点登录
         * @param casData
         */
        loginByCas: function(casData) {
            //清除外系统标识缓存
            window.sessionStorage.removeItem(cmedit.global.externalSystemCode);
            var pass_dog = false;
            //验证加密狗是否通过：true通过，false不通过
            $.ajax({
                type: 'POST',
                async: false,
                url: cmedit.global.cmsPath + 'CheckDogController/checkDog',
                dataType: 'json',
                success: function(data) {
                    pass_dog = data.data;
                }
            });

            if (pass_dog == true || pass_dog == "true") {
                if (isPublish) {
                    userId = casData.userId;
                    token = casData.token;
                    userName = casData.userName;
                    tenantId = casData.tenantId;
                    cloudType = casData.cloudType;
                    orgCode = casData.orgCode;
                } else {
                    userId = '0003';
                    token = 'biubiubiu';
                    userName = '0003';
                    tenantId = 'dayang';
                    cloudType = false;
                }



                if (userId == null || userId == "" || userId == undefined) {
                    alert("userId为空！")
                    return;
                }
                if (token == null || token == "" || token == undefined) {
                    alert("token为空")
                    return;
                }
                if (userName == null || userName == "" || userName == undefined) {
                    alert("userName为空！")
                    return;
                }
                if (tenantId == null || tenantId == "" || tenantId == undefined) {
                    alert("tenantId为空！")
                    return;
                }
                //console.log("单点登录成功")
                //window.location.href = 'views/manuscript/manuscript_list.html';
                $.ajax({
                    type: 'POST',
                    async: true,
                    url: cmedit.global.cmsPath + 'UserInfoController/loginBycas',
                    dataType: 'json',
                    data: {
                        cloudType: cloudType,
                        key: window.localStorage.getItem("portalKey"),
                        orgCode: orgCode,
                    },
                    beforeSend: function(XHR) {
                        XHR.setRequestHeader("userId", encodeURIComponent(userId));
                        XHR.setRequestHeader("tenantId", tenantId);
                        XHR.setRequestHeader("token", token);
                    },
                    complete : function(XHR){
                    	console.log("complete");
                    	var enable = XHR.getResponseHeader("enableRedirect");
                    	console.log("enableRedirect = " + enable);
                    	if(enable){
                    		alert("会话过期！！");
                    		var url = XHR.getResponseHeader("redirectUrl");
                    		console.log("redirectUrl = " + url);
                    		window.sessionStorage.clear();
                            window.top.location.href = url;
                    	}
                    },
                    success: function(data) {
                        if (data.status == true) {
                            window.sessionStorage.setItem(cmedit.global.userInfo, JSON.stringify(data.data));
                            var privilegeList = data.data.privilegeList;
                            var bigColumnId = data.data.bigColumnId;
                            var privilegeIds = [];
                            var userColumnIds = [];
                            var allColumnIds = [];
                            var columnList = data.data.columnList;
                            var CFBFlag = data.data.CFBFlag;
                            var CREFlag = data.data.CREFlag;
                            var lanYunFlag = data.data.lanYunFlag;
                            var daGuanFlag = data.data.daGuanFlag;
                            var rabbitmqFlag = data.data.rabbitmqFlag;
                            var rongZhiLianFlag = data.data.rongZhiLianFlag;
                            var rongYunFlag = data.data.rongYunFlag;
                            var rongYunRRFlag = data.data.rongYunRRFlag;
                            var rongYunTAFlag = data.data.rongYunTAFlag;
                            var rongYunMCFlag = data.data.rongYunMCFlag;
                            var hogeFlag = data.data.hogeFlag;
                            var saveAutoFlag = data.data.saveAutoFlag;
                            var saveInterval = data.data.saveInterval;
                            var creImportTaskFlag = data.data.creImportTaskFlag;
                            var CFBExternalUrl = data.data.CFBExternalUrl;
                            var CREFuncFlag = data.data.CREFuncFlag;
                            var lvFuncFlag = data.data.lvFuncFlag;
                            var cmeditList = data.data.cmeditList;
                            var distributeFlag = data.data.distributeFlag;
                            var GifFlag = data.data.gifFlag;
                            var SubtitleFlag = data.data.subtitleFlag;
                            var distributeSecretFlag = data.data.distributeSecretFlag;
                            var sitId = data.data.sitId;
                            var ccbvFlag = data.data.ccbvFlag;
                            window.sessionStorage.setItem("sitId",sitId);
                            window.sessionStorage.setItem(cmedit.global.privilegeInfo, JSON.stringify(privilegeList));
                            window.sessionStorage.setItem(cmedit.global.columnInfo, JSON.stringify(columnList));
                            window.sessionStorage.setItem(cmedit.global.cmeditTypes, JSON.stringify(cmeditList));
                            for (var i = 0; i < privilegeList.length; i++) {
                                privilegeIds.push(privilegeList[i].id);
                            }
                            for (var i = 0; i < columnList.length; i++) {
                                userColumnIds.push(columnList[i].id);
                            }
                            //将权限id集合，栏目id集合放入sessionStorage
                            window.sessionStorage.setItem(cmedit.global.privilegeIds, JSON.stringify(privilegeIds));
                            window.sessionStorage.setItem(cmedit.global.userColumnIds, JSON.stringify(userColumnIds));
                            window.sessionStorage.setItem(cmedit.global.CFBFlag, CFBFlag);
                            window.sessionStorage.setItem(cmedit.global.CREFlag, CREFlag);
                            window.sessionStorage.setItem(cmedit.global.daGuanFlag, daGuanFlag)
                            window.sessionStorage.setItem(cmedit.global.lanYunFlag, lanYunFlag);
                            window.sessionStorage.setItem(cmedit.global.rabbitmqFlag, rabbitmqFlag);
                            window.sessionStorage.setItem(cmedit.global.rongZhiLianFlag, rongZhiLianFlag);
                            window.sessionStorage.setItem(cmedit.global.rongYunFlag, rongYunFlag);
                            window.sessionStorage.setItem(cmedit.global.rongYunRRFlag, rongYunRRFlag);
                            window.sessionStorage.setItem(cmedit.global.rongYunTAFlag, rongYunTAFlag);
                            window.sessionStorage.setItem(cmedit.global.rongYunMCFlag, rongYunMCFlag);
                            window.sessionStorage.setItem(cmedit.global.hogeFlag, hogeFlag);
                            window.sessionStorage.setItem(cmedit.global.saveAutoFlag, saveAutoFlag);
                            window.sessionStorage.setItem(cmedit.global.saveInterval, saveInterval);
                            window.sessionStorage.setItem(cmedit.global.creImportTaskFlag, creImportTaskFlag);
                            window.sessionStorage.setItem(cmedit.global.CFBExternalUrl, CFBExternalUrl);
                            window.sessionStorage.setItem(cmedit.global.bigColumnId, bigColumnId);
                            window.sessionStorage.setItem(cmedit.global.CREFuncFlag, CREFuncFlag);
                            window.sessionStorage.setItem(cmedit.global.lvFuncFlag, lvFuncFlag);
                            window.sessionStorage.setItem("distributeFlag", distributeFlag);
                            window.sessionStorage.setItem(cmedit.global.GifFlag, GifFlag);
                            window.sessionStorage.setItem(cmedit.global.SubtitleFlag, SubtitleFlag);
                            window.sessionStorage.setItem("distributeSecretFlag", distributeSecretFlag);
                            window.sessionStorage.setItem("creCbbvFlag",ccbvFlag);
                            console.log("单点登录成功");
                            /*  var cmsFiled_list = thisContext.queryFiledList("CMS", "LIST");
                             var cmsFiled_sendtask = thisContext.queryFiledList("CMS", "SENDTASK");
                             var cmsFiled_task = thisContext.queryFiledList("CMS", "TASK");
                             var cmsFiled_send = thisContext.queryFiledList("CMS", "SEND");
                             var cmsFiled_download = thisContext.queryFiledList("CMS", "DOWNLOAD");
                             var cmsFiled_recycle = thisContext.queryFiledList("CMS", "RECYCLE");
                             //							var cmsFiled_edit = thisContext.queryFiledList("CMS","EDIT");
                             var cmsFiled_final = thisContext.queryFiledList("CMS", "FINAL");
                             window.sessionStorage.setItem(cmedit.global.cmeditList, cmsFiled_list);
                             window.sessionStorage.setItem(cmedit.global.cmeditSendTask, cmsFiled_sendtask);
                             window.sessionStorage.setItem(cmedit.global.cmeditTask, cmsFiled_task);
                             window.sessionStorage.setItem(cmedit.global.cmeditSend, cmsFiled_send);
                             window.sessionStorage.setItem(cmedit.global.cmeditDownload, cmsFiled_download);
                             window.sessionStorage.setItem(cmedit.global.cmeditRecycle, cmsFiled_recycle);
                             //							window.sessionStorage.setItem(cmedit.global.cmeditEdit,cmsFiled_edit);
                             window.sessionStorage.setItem(cmedit.global.cmeditFinal, cmsFiled_final); */
                            $.when(thisContext.queryFiledList("CMS", "LIST"),
                                thisContext.queryFiledList("CMS", "SENDTASK"),
                                thisContext.queryFiledList("CMS", "TASK"),
                                thisContext.queryFiledList("CMS", "SEND"),
                                thisContext.queryFiledList("CMS", "DOWNLOAD"),
                                thisContext.queryFiledList("CMS", "RECYCLE"),
                                thisContext.queryFiledList("CMS", "FINAL"),
                                thisContext.initHogeColumnFlag()).then(
                                function() {
                                    // 对大采访部逻辑进行处理
                                    if (userColumnIds.indexOf(bigColumnId) > 0) {
                                        var allColumnList = thisContext.getAllColumnList();
                                        for (var i = 0; i < allColumnList.length; i++) {
                                            allColumnIds.push(allColumnList[i].id);
                                        }
                                        window.sessionStorage.setItem(cmedit.global.allColumnInfo, JSON.stringify(allColumnList));
                                        window.sessionStorage.setItem(cmedit.global.allColumnIds, JSON.stringify(allColumnIds));
                                    } else {
                                        window.sessionStorage.setItem(cmedit.global.allColumnInfo, JSON.stringify(columnList));
                                        window.sessionStorage.setItem(cmedit.global.allColumnIds, JSON.stringify(userColumnIds));
                                    }
                                    if (privilegeIds.indexOf("PID_CMEDIT_FINALCENSOR") > -1) {
                                        window.location.href = 'views/manuscript/manuscript_list_finalcensor.html';
                                    } else {
                                        // 将存放一键稿件信息的key放在webStorage中
                                    	debugger;
                                        var externalKey = cmedit.global.getParameterFromUrl("externalKey");
                                        if (cmedit.global.isNotEmpty(externalKey)) {
                                        	if(externalKey.indexOf("__withouUserinfo") > -1){
                                        		console.log("当前为无用户信息一键稿件模式");
                                        		$.ajax({
                                    				type : 'POST',
                                    				async : false,
                                    				url : cmedit.global.cmsPath + 'OneKeyManuscriptController/oneKeyManuscriptWithoutUser',
                                    				dataType : 'json',
                                    				data : {
                                    					key : externalKey.replace("__withouUserinfo","")
                                    				},
                                    				beforeSend: function (XHR) {
                                    					XHR.setRequestHeader("userId", encodeURIComponent(userId));
                                    					XHR.setRequestHeader("userName", encodeURIComponent(userName));
                                                        XHR.setRequestHeader("tenantId", tenantId);
                                                        XHR.setRequestHeader("token", token);
                                    				},
                                    				success : function(data) {
                                    					var cmsManuscript = data.data;
                                                        var mainGuid = cmsManuscript.mainGuid;
                                                        var mainHeader = cmsManuscript.mainHeader.replace(/&amp;/g, "&");
                                                        externalKey = mainGuid + "_ONEKEY_" + mainHeader;
                                    				}
                                        		});
                                        	}
                                            window.sessionStorage.setItem("externalKey", externalKey);
                                        }
                                        window.location.href = 'views/manuscript/manuscript_list.html';
                                    }
                                })

                        } else {
                            alert(data.msg);
                        }
                    }
                });
            } else { //加密狗验证不通过
                //alert("未检测到加密点，请联系管理员！");
                $.warningNoDog();
            }
        },
        /**
         * 获取全部栏目【大采访部模式下使用】
         */
        getAllColumnList: function(columnList) {
            $.ajax({
                type: 'POST',
                async: false,
                url: cmedit.global.cmsPath + 'UserInfoController/getUserColumnByUserId',
                dataType: 'json',
                data: {
                    userType: "ALL",
                    key: window.localStorage.getItem("portalKey"),
                    orgCode: orgCode,
                },
                beforeSend: function(XHR) {
                    XHR.setRequestHeader("userId", encodeURIComponent(userId));
                    XHR.setRequestHeader("tenantId", tenantId);
                    XHR.setRequestHeader("token", token);
                },
                success: function(data) {
                    if (data.status == true) {
                        columnList = data.data;
                    } else {
                        console.log("获取全部栏目失败！！");
                    }
                }
            });
            return columnList;
        },
        /**
         * 根据userid获取用户详情
         */
        selectUserInfoByUserId: function() {
            $.ajax({
                async: false,
                url: cmedit.global.cmsPath +
                    "UserInfoController/getUserInfoByUserId",
                type: 'POST',
                dataType: 'json',
                data: { "key": window.localStorage.getItem("portalKey") },
                beforeSend: function(XHR) {
                    XHR.setRequestHeader("userId", encodeURIComponent(userId));
                    XHR.setRequestHeader("tenantId", tenantId);
                    XHR.setRequestHeader("token", token);
                },
                success: function(data) {
                    if (data.status == true || data.status == 'true') {
                        var userInfoDetail = data.data[0];
                        if (cmedit.global.isNotEmpty(userInfoDetail)) {
                            window.sessionStorage.setItem(cmedit.global.userInfoDetail, JSON.stringify(userInfoDetail));
                        } else {
                            cmedit.global.forceLogout("用户信息为空！");
                            return;
                        }
                    } else {
                        alert(data.msg);
                    }
                }
            });
        },
        /**
         * 用户栏目的获取
         */
        selectUserColumnByUserId: function() {

            $.ajax({
                async: false,
                url: cmedit.global.cmsPath +
                    "UserInfoController/getUserColumnByUserId",
                type: 'POST',
                dataType: 'json',
                data: { "key": window.localStorage.getItem("portalKey") },
                beforeSend: function(XHR) {
                    XHR.setRequestHeader("userId", encodeURIComponent(userId));
                    XHR.setRequestHeader("tenantId", tenantId);
                    XHR.setRequestHeader("token", token);
                },
                success: function(data) {
                    if (data.status == true || data.status == 'true') {
                        window.sessionStorage.setItem(cmedit.global.columnInfo, JSON.stringify(data.data));
                    } else {
                        alert(data.msg);
                    }
                }
            });
        },

        /**
         * 用户权限的获取
         */
        selectUserPrivilegeByUserId: function() {
            $.ajax({
                async: false,
                url: cmedit.global.cmsPath +
                    "UserInfoController/getPrivilegeByUserId",
                type: 'POST',
                dataType: 'json',
                data: { "key": window.localStorage.getItem("portalKey") },
                beforeSend: function(XHR) {
                    XHR.setRequestHeader("userId", encodeURIComponent(userId));
                    XHR.setRequestHeader("tenantId", tenantId);
                    XHR.setRequestHeader("token", token);
                },
                success: function(data) {
                    if (data.status == true || data.status == 'true') {
                        window.sessionStorage.setItem(cmedit.global.privilegeInfo, JSON.stringify(data.data));
                    } else {
                        alert(data.msg);
                    }
                }
            });
        },
        /**
         * 获取厚键栏目是否开启
         */
        initHogeColumnFlag: function() {
        	var hogeColumnFlag = '0';
        	$.ajax({
                type: 'POST',
                async: false,
				url: cmedit.global.portalPath + "ParameterController/getParameter",
				beforeSend: function (XHR) {
                    XHR.setRequestHeader("userId", userId);
                    XHR.setRequestHeader("tenantId", tenantId);
                    XHR.setRequestHeader("token", token);
                },
				data: {
					parameterCode : "EDIT_HOGE_COLUMNADDRESS"
				},
                success: function (data) {
                    if (data.status == true || data.status == "true") {
                    	var parameterValue = data.data[0].parameterValue;
                    	if(cmedit.global.isNotEmpty(parameterValue) && parameterValue != '-' && parameterValue.indexOf("http") > -1){
                    		hogeColumnFlag = '1';
                    	}
                    }
                }
            });
        	window.sessionStorage.setItem("hogeColumnFlag", hogeColumnFlag);
        },
        /**
         * 查询当前的字段配置数据
         */
        /*  queryFiledList: function(modelName, viewTarget) {
             var fieldList;
             $.ajax({
                 async: false,
                 url: cmedit.global.portalPath +
                     "fieldconfig/queryFieldConfig",
                 type: 'POST',
                 dataType: 'json',
                 data: {
                     "ownColumnId": "PUB_DEFAULT_COLUMN",
                     "modelName": modelName,
                     "viewTarget": viewTarget,

                 },
                 beforeSend: function(XHR) {
                     XHR.setRequestHeader("userId", userId);
                     XHR.setRequestHeader("tenantId", tenantId);
                     XHR.setRequestHeader("token", token);
                 },
                 success: function(data) {
                     if (data.status == true || data.status == 'true') {
                         //						window.sessionStorage.setItem("cmeditFiled_form",JSON.stringify(data.data));
                         fieldList = JSON.stringify(data.data);
                     } else {
                         console.log("查询稿件字段配置信息失败");
                     }
                 }
             });
             return fieldList;
         }, */
        queryFiledList: function(modelName, viewTarget) {
            var fieldList;
            $.ajax({
                async: false,
                url: cmedit.global.portalPath +
                    "fieldconfig/queryFieldConfig",
                type: 'POST',
                dataType: 'json',
                data: {
                    "ownColumnId": "PUB_DEFAULT_COLUMN",
                    "modelName": modelName,
                    "viewTarget": viewTarget,
                },
                beforeSend: function(XHR) {
                    XHR.setRequestHeader("userId", encodeURIComponent(userId));
                    XHR.setRequestHeader("tenantId", tenantId);
                    XHR.setRequestHeader("token", token);
                },
                success: function(data) {
                    if (data.status == true || data.status == 'true') {
                        fieldList = JSON.stringify(data.data);
                        switch (viewTarget) {
                            case "LIST":
                                window.sessionStorage.setItem(cmedit.global.cmeditList, fieldList);
                                break;
                            case "SENDTASK":
                                window.sessionStorage.setItem(cmedit.global.cmeditSendTask, fieldList);
                                break;
                            case "TASK":
                                window.sessionStorage.setItem(cmedit.global.cmeditTask, fieldList);
                                break;
                            case "SEND":
                                window.sessionStorage.setItem(cmedit.global.cmeditSend, fieldList);
                                break;
                            case "DOWNLOAD":
                                window.sessionStorage.setItem(cmedit.global.cmeditDownload, fieldList);
                                break;
                            case "RECYCLE":
                                window.sessionStorage.setItem(cmedit.global.cmeditRecycle, fieldList);
                                break;
                            case "FINAL":
                                window.sessionStorage.setItem(cmedit.global.cmeditFinal, fieldList);
                                break;
                        }
                    } else {
                        console.log("查询稿件字段配置信息失败");
                    }
                }
            });
        },
    };
    return new LoginBycasClass();
})(jQuery, window, document);

//优先动态加载css和js后执行页面初始化方法
$.getScript(cmedit.global.getPortalWeb() + 'static/scripts/utils/headerPlugin.min.js',function(){  //加载js,成功后，并执行回调函数  ; 
	//向域对象下存储portalPath地址，以便在headerPlugin插件中使用
	window.sessionStorage.setItem("portalPath",cmedit.global.portalPath);
	var headerHeight = "110px";
    if (typeof $.getHeaderHeight == 'function') {
        headerHeight = $.getHeaderHeight();
    }
    window.sessionStorage.setItem("headerHeight", headerHeight);
    // 页面加载完毕后初始化方法调用
    $(cmedit.LoginBycas.init());
});;
